<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>axios</title>
      <script src="js/axios-0.18.0.js"></script>
</head>
<body>

<input type="button" value="获取数据" onclick="getData()">
<input type="button" value="set数据" onclick="setData()">
<div id="div1"></div>

</body>
<script>

    function getData(){
        axios.get("http://localhost:8080/login admin").then(result => {
            document.getElementById("div1").innerHTML=result.data[1].account;
        })
        // axios({
        //     method:"get",
        //     url:"http://localhost:8080/login admin"
        // }).then( result => {
        //     console.log(result.data);
        //     document.getElementById("div1").innerHTML=result.data[1].account;
        // });
    }
    function setData(){
        const data = {
            account:"1",
            password:"21"
        };
        axios.withCredentials=true;
        axios.post("http://localhost:8080/login admin",data).then(result => {
           console.log("成功")
        })


        //如果在网址处有/id  那第二个就改为"id=1"
        //axios.post("http://localhost:8080/login admin","id=1").then(result => {
    //     console.log("成功")
    // })


        // axios({
        //     method: "post",
        //     url: "http://localhost:8080/login stu",
        //     data:{
        //         account:"123333",
        //         password:"1232"
        //     }
        // }).then(result => {
        //     console.log("成功");
        // })
    }


</script>
</html>